package com.yin.myproject.util;

import com.yin.myproject.core.ScheduleTask;
import org.apache.commons.lang3.StringUtils;

/**
 * @author Eason
 * @create 2018-04-08 10:13
 **/
public class TaskKeyUtil {
    /**
     * 构建任务标识
     *
     * @param task
     * @return
     */
    public static String buildKey(ScheduleTask task) {
        if (!StringUtils.isEmpty(task.getTargetBean())) {
            return task.getTargetBean() + "#" + task.getTargetMethod();
        } else if (!StringUtils.isEmpty(task.getTargetClazz())) {
            return task.getTargetClazz() + "#" + task.getTargetMethod();
        }
        throw new RuntimeException("the key and targetBean and targetClazz of task are null. Must one is not null.");
    }
}
